package com.showtao.front.dto;

import java.io.Serializable;

import com.showtao.front.domain.Catalog;

@SuppressWarnings("serial")
public class CatalogDto implements Serializable {

    private Long id;
    private String name;
    private String alias;
    private Long parentId;
    private String parentName;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }
    
    public static CatalogDto from(Catalog catalog){
        CatalogDto dto = new CatalogDto();
        dto.setId(catalog.getId());
        dto.setName(catalog.getName());
        dto.setAlias(catalog.getAlias());
        if(catalog.getParent() != null){
            dto.setParentId(catalog.getParent().getId());
            dto.setParentName(catalog.getParent().getName());
        }
        return dto;
    }
}
